package javase.reflection;


public class TypeObtainer {

	public static void main(String[] args) {
		TypeObtainer instance = new TypeObtainer();
		System.out.println(instance.getSpecificClassLiteralByName().getSimpleName());
		System.out.println(instance.getSpecificClassByName().getSimpleName());
		System.out.println(instance.getSpecificClassFromInstance().getSimpleName());
	}

	@SuppressWarnings("unchecked")
	public Class<?> getSpecificClassByName() {
		Class<Specific> result = null;
		try {
			result = (Class<Specific>) Class.forName("javase.reflection.Specific");
		} catch (ClassNotFoundException e) {
			System.out.println("Class javase.reflection.Specific not found.");
			e.printStackTrace();
		}
		return result;
	}
	
	public Class<?> getSpecificClassLiteralByName() {
		return Specific.class;
	}
	
	public Class<?> getSpecificClassFromInstance() {
		Object castedSpecific = new Specific();
		return castedSpecific.getClass();
	}
}
